//
//  TeamBaseInfoController.m
//  RedballBar
//
//  Created by Faith  on 2024/9/14.
//

#import "TeamBaseInfoController.h"
#import "TeamBaseInfoContestView.h"
#import "TeamBaseInfoProfileView.h"
#import "TeamBaseInfoTransferView.h"
#import "TeamBaseInfoHonorView.h"
#import "TeamBaseInfoTransferController.h"

@interface TeamBaseInfoController ()

/// 近期比赛控件
@property (nonatomic, strong) TeamBaseInfoContestView *contestView;

/// 球队资料控件
@property (nonatomic, strong) TeamBaseInfoProfileView *profileView;

/// 转会记录控件
@property (nonatomic, strong) TeamBaseInfoTransferView *transferView;

/// 球队荣誉控件
@property (nonatomic, strong) TeamBaseInfoHonorView *honorView;

@end

@implementation TeamBaseInfoController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    // 5像素分割线
    UIView *firstLine = [[UIView alloc] init];
    firstLine.backgroundColor = [UIColor colorWithHexString:@"#F1F1F1"];
    [self.container addSubview:firstLine];
    [firstLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.container);
        make.left.equalTo(self.container);
        make.right.equalTo(self.container);
        make.height.mas_equalTo(SIZE(5));
    }];
    
    // 近期赛事
    [self.container addSubview:self.contestView];
    [self.contestView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(firstLine.mas_bottom);
        make.left.and.right.equalTo(self.container);
    }];
    
    // 5像素分割线
    UIView *secondLine = [[UIView alloc] init];
    secondLine.backgroundColor = [UIColor colorWithHexString:@"#F1F1F1"];
    [self.container addSubview:secondLine];
    [secondLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contestView.mas_bottom).offset(SIZE(15));
        make.left.equalTo(self.container);
        make.right.equalTo(self.container);
        make.height.mas_equalTo(SIZE(5));
    }];
    
    // 球队资料
    [self.container addSubview:self.profileView];
    [self.profileView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(secondLine.mas_bottom);
        make.left.and.right.equalTo(self.container);
    }];
    
    // 5像素分割线
    UIView *thirdLine = [[UIView alloc] init];
    thirdLine.backgroundColor = [UIColor colorWithHexString:@"#F1F1F1"];
    [self.container addSubview:thirdLine];
    [thirdLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.profileView.mas_bottom).offset(SIZE(15));
        make.left.equalTo(self.container);
        make.right.equalTo(self.container);
        make.height.mas_equalTo(SIZE(5));
    }];
    
    // 转会记录
    [self.container addSubview:self.transferView];
    [self.transferView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(thirdLine.mas_bottom);
        make.left.and.right.equalTo(self.container);
    }];
    
    // 5像素分割线
    UIView *fourLine = [[UIView alloc] init];
    fourLine.backgroundColor = [UIColor colorWithHexString:@"#F1F1F1"];
    [self.container addSubview:fourLine];
    [fourLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.transferView.mas_bottom).offset(SIZE(15));
        make.left.equalTo(self.container);
        make.right.equalTo(self.container);
        make.height.mas_equalTo(SIZE(5));
    }];
    
    // 荣誉记录
    [self.container addSubview:self.honorView];
    [self.honorView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(fourLine.mas_bottom);
        make.left.and.right.equalTo(self.container);
    }];
    
    // 完成布局
    [self completeContainer:self.honorView inTabbar:NO];
    
    // 加载数据
    [self loadData];
    
}

/// 懒加载近期赛事
- (TeamBaseInfoContestView *)contestView {
    if(!_contestView) {
        _contestView = [[TeamBaseInfoContestView alloc] init];
    }
    return _contestView;
}

/// 懒加载近期赛事
- (TeamBaseInfoProfileView *)profileView {
    if(!_profileView) {
        _profileView = [[TeamBaseInfoProfileView alloc] init];
    }
    return _profileView;
}

/// 懒加载转会记录
- (TeamBaseInfoTransferView *)transferView {
    if(!_transferView) {
        _transferView = [[TeamBaseInfoTransferView alloc] init];
        __weak typeof(self) weakSelf = self;
        [_transferView setMoreClick:^{
            TeamBaseInfoTransferController *teamBaseInfoTransferController = [[TeamBaseInfoTransferController alloc] init];
            [weakSelf pushViewController:teamBaseInfoTransferController];
        }];
    }
    return _transferView;
}

/// 懒加载荣誉记录
- (TeamBaseInfoHonorView *)honorView {
    if(!_honorView) {
        _honorView = [[TeamBaseInfoHonorView alloc] init];
    }
    return _honorView;
}

/// 加载数据
- (void)loadData {
    // 刷新赛事数据
    NSArray *contestData = @[
        @{
            @"contestName": @"天皇杯",
            @"contestDate": @"08-21 18:00",
            @"contestInfoMain": @"中日德兰",
            @"contestInfoAway": @"布拉迪德",
            @"schemeSummary": @"含14个方案"
        },
        @{
            @"contestName": @"欧冠杯",
            @"contestDate": @"08-31 08:00",
            @"contestInfoMain": @"基辅迪兰",
            @"contestInfoAway": @"萨尔茨迪",
            @"schemeSummary": @"含14个方案"
        }
    ];
    [self.contestView setData:contestData];
    
    NSArray *profileData = @[
        @{
            @"title": @"成立时间",
            @"value": @"1928年"
        },
        @{
            @"title": @"主教练",
            @"value": @"帕特里克·范列文"
        },
        @{
            @"title": @"球场",
            @"value": @"金属工人球场"
        },
        @{
            @"title": @"球场容量",
            @"value": @"40000人"
        }
    ];
    [self.profileView setData:profileData];
    
    NSArray *transferData = @[
        @{
            @"avatar": @"https://wx1.sinaimg.cn/orj360/7767ca7fly1htm65kimd6j21bf0zkalb.jpg",
            @"name": @"德米特里·尤索夫德米特里·尤索夫德米特里·尤索夫德米特里·尤索夫德米特里·尤索夫德米特里·尤索夫德米特里·尤索夫德米特里·尤索夫德米特里·尤索夫德米特里·尤索夫",
            @"date": @"2024-08-20 21:10",
            @"transferTeam": @"敖德萨黑海人",
            @"transferDirection": @"out",
            @"transferSummary": @"转出"
        },
        @{
            @"avatar": @"https://wx4.sinaimg.cn/orj360/7767ca7fly1htm65ljtdmj218a0zkk3p.jpg",
            @"name": @"德米特里·尤索夫",
            @"date": @"2024-08-20 21:10",
            @"transferTeam": @"-",
            @"transferDirection": @"in",
            @"transferSummary": @"转入"
        },
        @{
            @"avatar": @"https://wx3.sinaimg.cn/orj360/7767ca7fly1htm65p1u08j21bf0zkqiz.jpg",
            @"name": @"安德里·特卡楚克",
            @"date": @"2024-08-20 21:10",
            @"transferTeam": @"敖德萨黑海人",
            @"transferDirection": @"out",
            @"transferSummary": @"转出"
        },
        @{
            @"avatar": @"https://wx3.sinaimg.cn/orj360/5bc65f79gy1htn4y7dyzbj20u0190qah.jpg",
            @"name": @"安德里·特卡楚克",
            @"date": @"2024-08-20 21:10",
            @"transferTeam": @"-",
            @"transferDirection": @"out",
            @"transferSummary": @"转出"
        }
    ];
    [self.transferView setData:transferData];
    
    NSArray *honorData = @[
        @{
            @"icon": @"https://wx1.sinaimg.cn/orj360/7767ca7fly1htm65kimd6j21bf0zkalb.jpg",
            @"name": @"欧洲杯冠军",
            @"tags": @[@"2012", @"2008", @"1964", @"2024",@"2012", @"2008", @"1964", @"2024",@"2012", @"2008", @"1964", @"2024"],
        },
        @{
            @"icon": @"https://wx4.sinaimg.cn/orj360/7767ca7fly1htm65ljtdmj218a0zkk3p.jpg",
            @"name": @"世界杯冠军",
            @"tags": @[@"2010", @"2009-2010",@"2010", @"2009-2010",@"2010", @"2009-2010",@"2010", @"2009-2010",@"2010", @"2009-2010",@"2010", @"2009-2010",@"2010", @"2009-2010"],
        },
        @{
            @"icon": @"https://wx3.sinaimg.cn/orj360/7767ca7fly1htm65p1u08j21bf0zkqiz.jpg",
            @"name": @"奥运会第二名",
            @"tags": @[@"2010", @"2009-2010",@"2010", @"2009-2010",@"2010", @"2009-2010",@"2010", @"2009-2010",@"2010", @"2009-2010",@"2010", @"2009-2010",@"2010", @"2009-2010"],
        }
    ];
    [self.honorView setData:honorData];
}

@end
